package com.mg.framework.tiled;

public class Rectangle {

	public int x;
	public int y;
	public int width;
	public int height;

	public Rectangle() {

	}
	
	public Rectangle(int width, int height) {
		this.width = width;
		this.height = height;
	}
	
	public Rectangle(int x2, int y2, int width2, int height2) {
		x = x2;
		y = y2;
		width = width2;
		height = height2;
	}

	public Rectangle(Rectangle r) {
		setBounds(r);
	}
	
	private void setBounds(Rectangle r) {
		x = r.x;
		y = r.y;
		width = r.width;
		height = r.height;
	}

	public Rectangle(Dimension tileDimensions) {
		this.width = tileDimensions.width;
		this.height = tileDimensions.height;
	}

	public boolean contains(int x2, int y2) {
		if ((width | height) < 0) {
			return false;
		}
		if (x2 < x || y2 < y) {
			return false;
		}
		int w = x + width;
		int h = y + height;
		return ((w < x || w > x2) && (h < y || h > y2));
	}
}
